<?php
//session_name(DicomScience);
//session_start();

/*
 * The readMedia.php Controller listens on the following hhtp_get options:
 * - "lastdays" an integer for last_modified (media and images)
 * - "media" an integer representing the media ID
 * - *image* an integer representing the image ID (DICOM Image)
 * - "search" a string searchable in all media and image fields
 * - "editor" an integer representing the uploading author of the media
 * The controller always responds in an XML coded http - Datastream. 
 */

$lastdays = $_GET['lastdays'];
$mediaId = $_GET['media'];
$imageId = $_GET['image'];
$searchString = $_GET['search'];
$mediaEditor = $_GET['editor'];

$now = time();
$oneday = 86400;
$range = $lastdays * $oneday;
$lastdate = $now - $range;

/*
 * ACTION TRIGGER: which response is appropriate?
 */
if (! $lastdays == ""){
	# See Section GETLIST
	getList($lastdate);
} elseif (! $mediaId == ""){
	# See Section GETMEDIABYNUMBER
	getMediaByNumber($mediaId);
} elseif (! $imageId == ""){
	# See Section GETIMAGEBYNUMBER
	getImageByNumber($imageId);	
} elseif (! $searchString == ""){
	# See Section GETBYSEARCH
	getBySearch($searchString);
} elseif (! $mediaEditor == ""){
	# See Section GETMEDIABYEDITOR
	getMediaByEditor($mediaEditor);
}


/*
 * SECTION GETLIST BY DATE
 */
function getList($lastdate){
	
	require('../includes/gset.php');
	
	$sql_getMedia = "SELECT id_media, tags, modality, organ, location_thumb, location_media, firstname, lastname, upload_date, media_type FROM media, staff WHERE upload_date > $lastdate AND (media.upload_user = staff.id_staff)";
	$sql_getImage = "SELECT id_image, tags, modality, organ, location_thumb, location_image, upload_date, window_center, window_width, laterality, image_comment, contrast, mr_aquisitiontype, sequence_name, slice_thickness, kv, protocol_name, kernel, mr_coil, flip_angle, pat_pos, sens, manufacturer, firstname, lastname FROM image, staff WHERE upload_date > $lastdate AND (image.upload_user = staff.id_staff)";
	
	include ('../includes/database/connect.php');
	$getMedia = mysql_query($sql_getMedia);
	$getImages = mysql_query($sql_getImage);
	include ('../includes/database/closedb.php');	
	
	// Writing XML Response Header
	header("Content-type: text/xml"); 
	echo "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>";
	echo "<mediaList>";
			while ($mList = mysql_fetch_object($getMedia)){
				
				$id_media = $mList->id_media;
				$tags = $mList->tags;
				$modality = $mList->modality;
				$organ = $mList->organ;
				$location_thumb = $mList->location_thumb;
				$location_media = $mList->location_media;
				$upload_date = $mList->upload_date;
				$upload_user = $mList->upload_user;
				$media_type = $mList->media_type; 
				$firstname = $mList->firstname;
				$lastname = $mList->lastname;
				
				$date = getDisplayDate($upload_date);
				
				echo "<media>";
					echo "<mediaId>";
					echo $id_media;
					echo "</mediaId>";
					echo "<mediaType>";
					echo $media_type;
					echo "</mediaType>";
					echo "<tags>";
					echo $tags;
					echo "</tags>";
					echo "<modality>";
					echo $modality;
					echo "</modality>";
					echo "<organ>";
					echo $organ;
					echo "</organ>";
					echo "<thumbnail>";
					echo $location_thumb;
					echo "</thumbnail>";
					echo "<mediaLocator>";
					echo $location_media;
					echo "</mediaLocator>";
					echo "<mediaEditor>";
					echo $firstname." ".$lastname;
					echo "</mediaEditor>";
					echo "<uploadDate>";
					echo $date;
					echo "</uploadDate>";
					echo "<windowCenter></windowCenter>";
                    echo "<windowWidth></windowWidth>";                                  
                    echo "<laterality></laterality>";
                    echo "<imageComment></imageComment>";
                    echo "<contrast></contrast>";
                    echo "<mrAquisitionType></mrAquisitionType>";
                    echo "<sequenceName></sequenceName>";
                    echo "<sliceThickness></sliceThickness>";
                    echo "<kV></kV>";
                    echo "<protocolName></protocolName>";
                    echo "<kernel></kernel>";
                    echo "<mrCoil></mrCoil>";
                   	echo "<flipAngle></flipAngle>";
                    echo "<patPos></patPos>";
                   	echo "<sens></sens>";
                    echo "<manufacturer></manufacturer>";
				echo "</media>";
				
			}
			
			while($iList = mysql_fetch_object($getImages)){
				
				$id_image = $iList->id_image;
				$media_type = $iList->media_type;
				$tags = $iList->tags;
				$modality = $iList->modality;
				$organ = $iList->organ;
				$thumbnail = $iList->location_thumb;
				$mediaLocator = $iList->location_image;
				$lastname = $iList->lastname;
				$firstname = $iList->firstname;
				$upload_date = $iList->upload_date;
				$windowCenter = $iList->window_center;
				$windowWidth = $iList->window_width;
				$lat = $iList->laterality;
				$imageComment = $iList->image_comment;
				$contrast = $iList->contrast;
				$mrAquistitionType = $iList->mr_aquisitiontype;
				$sequenceName = $iList->sequence_name;
				$sliceThickness = $iList->slice_thickness;
				$kv = $iList->kv;
				$protocolName = $iList->protocol_name;
				$kernel = $iList->kernel;
				$mrCoil = $iList->mr_coil;
				$flipAngle = $iList->flip_angle;
				$patPos = $iList->pat_pos;
				$sens = $iList->sens;
				$man = $iList->manufacturer;
				
				$date = getDisplayDate($upload_date);
				
				echo "<media>";
					echo "<mediaId>";
					echo $id_image;
					echo "</mediaId>";
					echo "<mediaType>";
					echo $media_type;
					echo "</mediaType>";
					echo "<tags>";
					echo $tags;
					echo "</tags>";
					echo "<modality>";
					echo $modality;
					echo "</modality>";
					echo "<organ>";
					echo $organ;
					echo "</organ>";
					echo "<thumbnail>";
					echo $thumbnail;
					echo "</thumbnail>";
					echo "<mediaLocator>";
					echo $mediaLocator;
					echo "</mediaLocator>";
					echo "<mediaEditor>";
					echo $firstname." ".$lastname;
					echo "</mediaEditor>";
					echo "<uploadDate>";
					echo $date;
					echo "</uploadDate>";
					echo "<windowCenter>";
					echo $windowCenter;
					echo "</windowCenter>";
					echo "<windowWidth>";
					echo $windowWidth;
					echo "</windowWidth>";
					echo "<laterality>";
					echo $lat;
					echo "</laterality>";
					echo "<imageComment>";
					echo $imageComment;
					echo "</imageComment>";
					echo "<contrast>";
					echo $contrast;
					echo "</contrast>";
					echo "<mrAquisitionType>";
					echo $mrAquistitionType;
					echo "</mrAquisitionType>";
					echo "<sequenceName>";
					echo $sequenceName;
					echo "</sequenceName>";
					echo "<sliceThickness>";
					echo $sliceThickness;
					echo "</sliceThickness>";
					echo "<kV>";
					echo $kv;
					echo "</kV>";
					echo "<protocolName>";
					echo $protocolName;
					echo "</protocolName>";
					echo "<kernel>";
					echo $kernel;
					echo "</kernel>";
					echo "<mrCoil>";
					echo $mrCoil;
					echo "</mrCoil>";
					echo "<flipAngle>";
					echo $flipAngle;
					echo "</flipAngle>";
					echo "<patPos>";
					echo $patPos;
					echo "</patPos>";
					echo "<sens>";
					echo $sens;
					echo "</sens>";
					echo "<manufacturer>";
					echo $man;
					echo "</manufacturer>";
					
				echo "</media>";
			}
	
	echo "</mediaList>";
} 
 
/*
 * SECTION GETMEDIABYNUMBER
 */
function getMediaByNumber($mediaId){

	require('../includes/gset.php');
	$sql_getMedia = "SELECT id_media, tags, modality, upload_user, organ, location_thumb, location_media, firstname, lastname, upload_date, media_type FROM media, staff WHERE id_media = '$mediaId' AND (media.upload_user = staff.id_staff)";
	
	include ('../includes/database/connect.php');
	$getMedia = mysql_query($sql_getMedia);
	include ('../includes/database/closedb.php');
	
	// Writing XML Response Header
	header("Content-type: text/xml"); 
	echo "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>";
	echo "<mediaList>";
	
	while ($med = mysql_fetch_object($getMedia)){
		
		$idmedia = $med->id_media;
		$tags = $med->tags;
		$mod = $med->modality;
		$org = $med->organ;
		$thumb = $med->location_thumb;
		$media = $med->location_media;
		$firstname = $med->firstname;
		$lastname = $med->lastname;
		$type = $med->media_type;
		$lastmodified = $med->upload_date;
		$editorId = $med->upload_user;
		
		$date = getDisplayDate($lastmodified);
		
		echo "<media>";
			echo "<mediaId>";
			echo $idmedia;
			echo "</mediaId>";
			echo "<mediaType>";
			echo $type;
			echo "</mediaType>";
			echo "<tags>";
			echo $tags;
			echo "</tags>";
			echo "<modality>";
			echo $mod;
			echo "</modality>";
			echo "<organ>";
			echo $org;
			echo "</organ>";
			echo "<thumbnail>";
			echo $thumb;
			echo "</thumbnail>";
			echo "<mediaLocator>";
			echo $media;
			echo "</mediaLocator>";
			echo "<mediaEditor>";
			echo $firstname." ".$lastname;
			echo "</mediaEditor>";
			echo "<mediaEditorId>";
			echo $editorId;
			echo "</mediaEditorId>";
			echo "<uploadDate>";
			echo $date;
			echo "</uploadDate>";
		echo "</media>";
	}
	echo "</mediaList>";
	
} 
 
/*
 * SECTION GETIMAGEBYNUMBER
 */
function getImageByNumber($imageId){

	require('../includes/gset.php');
	$sql_getMedia = "SELECT id_image, tags, upload_user, modality, organ, location_thumb, location_image, upload_date, window_center, window_width, laterality, image_comment, contrast, mr_aquisitiontype, sequence_name, slice_thickness, kv, protocol_name, kernel, mr_coil, flip_angle, pat_pos, sens, manufacturer, firstname, lastname FROM image, staff WHERE id_image = '$imageId' AND (image.upload_user = staff.id_staff)";
	
	include ('../includes/database/connect.php');
	$getImage = mysql_query($sql_getMedia);
	include ('../includes/database/closedb.php');

	// Writing XML Response Header
	header("Content-type: text/xml"); 
	echo "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>";
	echo "<imageList>";
	
	while ($img = mysql_fetch_object($getImage)){
		
		$idimage = $img->id_image;
		$tags = $img->tags;
		$mod = $img->modality;
		$org = $img->organ;
		$thumb = $img->location_thumb;
		$image = $img->location_image;
		$lastmodified = $img->upload_date;
		$wc = $img->window_center;
		$ww = $img->window_width;
		$lat = $img->laterality;
		$ic = $img->image_comment;
		$con = $img->contrast;
		$mrat = $img->mr_aquisitiontype;
		$seq = $img->sequence_name;
		$st = $img->slice_thickness;
		$kv = $img->kv;
		$pn = $img->protocol_name;
		$kernel = $img->kernel;
		$mrc = $img->mr_coil;
		$fa = $img->flip_angle;
		$pp = $img->pat_pos;
		$sens = $img->sens;
		$man = $img->manufacturer;
		$firstname = $img->firstname;
		$lastname = $img->lastname;
		$editor = $img->upload_user;

		echo "<image>";
			echo "<imageId>";
			echo $idimage;
			echo "</imageId>";
			echo "<tags>";
			echo $tags;
			echo "</tags>";
			echo "<modality>";
			echo $mod;
			echo "</modality>";
			echo "<organ>";
			echo $org;
			echo "</organ>";
			echo "<thumbnail>";
			echo $thumb;
			echo "</thumbnail>";
			echo "<imageLocator>";
			echo $image;
			echo "</imageLocator>";
			echo "<mediaEditor>";
			echo $firstname." ".$lastname;
			echo "</mediaEditor>";
			echo "<mediaEditorId>";
			echo $editor;
			echo "</mediaEditorId>";
			echo "<uploadDate>";
			echo $date;
			echo "</uploadDate>";
			echo "<windowCenter>";
			echo $wc;
			echo "</windowCenter>";
			echo "<windowWidth>";
			echo $ww;
			echo "</windowWidth>";
			echo "<laterality>";
			echo $lat;
			echo "</laterality>";
			echo "<imageComment>";
			echo $ic;
			echo "</imageComment>";
			echo "<contrast>";
			echo $con;
			echo "</contrast>";
			echo "<mrAquisitionType>";
			echo $mrat;
			echo "</mrAquisitionType>";
			echo "<sequenceName>";
			echo $seq;
			echo "</sequenceName>";
			echo "<sliceThickness>";
			echo $st;
			echo "</sliceThickness>";
			echo "<kV>";
			echo $kv;
			echo "</kV>";
			echo "<protocolName>";
			echo $pn;
			echo "</protocolName>";
			echo "<kernel>";
			echo $kernel;
			echo "</kernel>";
			echo "<mrCoil>";
			echo $mrc;
			echo "</mrCoil>";
			echo "<flipAngle>";
			echo $fa;
			echo "</flipAngle>";
			echo "<patPos>";
			echo $pp;
			echo "</patPos>";
			echo "<sens>";
			echo $sens;
			echo "</sens>";
			echo "<manufacturer>";
			echo $man;
			echo "</manufacturer>";
			
		echo "</image>";
		
	}
	
	echo "</imageList>";
	
} 
 
/*
 * SECTION GETBYSEARCH
 */
function getBySearch($searchString){
	
	require('../includes/gset.php');
	
	$sql_getMedia = "SELECT upload_user, id_media, tags, modality, organ, location_thumb, location_media, firstname, lastname, upload_date, media_type FROM media, staff WHERE (tags like '%$searchString%' OR modality like '%$searchString%' OR organ like '%$searchString%' OR firstname like '%$searchString%' OR lastname like '%$searchString%') GROUP BY (id_media) ORDER BY (id_media) DESC";
	$sql_getImage = "SELECT upload_user, id_image, tags, modality, organ, location_thumb, location_image, upload_date, window_center, window_width, laterality, image_comment, contrast, mr_aquisitiontype, sequence_name, slice_thickness, kv, protocol_name, kernel, mr_coil, flip_angle, pat_pos, sens, manufacturer, firstname, lastname FROM image, staff WHERE (tags like '%$searchString%' OR modality like '%$searchString%' OR organ like '%$searchString%' OR window_center like '%$searchString%' OR window_width like '%$searchString%' OR laterality like '%$searchString%' OR image_comment like '%$searchString%' OR contrast like '%$searchString%' OR mr_aquisitiontype like '%$searchString%' OR sequence_name like '%$searchString%' OR slice_thickness like '%$searchString%' OR kv like '%$searchString%' OR protocol_name like '%$searchString%' OR kernel like '%$searchString%' OR mr_coil like '%$searchString%' OR flip_angle like '%$searchString%' OR pat_pos like '%$searchString%' OR sens like '%$searchString%' OR manufacturer like '%$searchString%' OR firstname like '%$searchString%' OR lastname like '%$searchString%') GROUP BY (id_image) ORDER BY (id_image) DESC";
	
	include ('../includes/database/connect.php');
	$getMedia = mysql_query($sql_getMedia);
	$getImages = mysql_query($sql_getImage);
	include ('../includes/database/closedb.php');
	
	// Writing XML Response Header
	header("Content-type: text/xml"); 
	echo "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>";
	echo "<mediaList>";
			while ($mList = mysql_fetch_object($getMedia)){
				
				$id_media = $mList->id_media;
				$tags = $mList->tags;
				$modality = $mList->modality;
				$organ = $mList->organ;
				$location_thumb = $mList->location_thumb;
				$location_media = $mList->location_media;
				$upload_date = $mList->upload_date;
				$upload_user = $mList->upload_user;
				$media_type = $mList->media_type; 
				$firstname = $mList->firstname;
				$lastname = $mList->lastname;
				$editor = $mList->upload_user;
				
				$date = getDisplayDate($upload_date);
				
				echo "<media>";
					echo "<mediaId>";
					echo $id_media;
					echo "</mediaId>";
					echo "<mediaType>";
					echo $media_type;
					echo "</mediaType>";
					echo "<tags>";
					echo $tags;
					echo "</tags>";
					echo "<modality>";
					echo $modality;
					echo "</modality>";
					echo "<organ>";
					echo $organ;
					echo "</organ>";
					echo "<thumbnail>";
					echo $location_thumb;
					echo "</thumbnail>";
					echo "<mediaLocator>";
					echo $location_media;
					echo "</mediaLocator>";
					echo "<mediaEditor>";
					echo $firstname." ".$lastname;
					echo "</mediaEditor>";
					echo "<mediaEditorId>";
					echo $editor;
					echo "</mediaEditorId>";
					echo "<uploadDate>";
					echo $date;
					echo "</uploadDate>";
					echo "<windowCenter></windowCenter>";
                    echo "<windowWidth></windowWidth>";                                  
                    echo "<laterality></laterality>";
                    echo "<imageComment></imageComment>";
                    echo "<contrast></contrast>";
                    echo "<mrAquisitionType></mrAquisitionType>";
                    echo "<sequenceName></sequenceName>";
                    echo "<sliceThickness></sliceThickness>";
                    echo "<kV></kV>";
                    echo "<protocolName></protocolName>";
                    echo "<kernel></kernel>";
                    echo "<mrCoil></mrCoil>";
                   	echo "<flipAngle></flipAngle>";
                    echo "<patPos></patPos>";
                   	echo "<sens></sens>";
                    echo "<manufacturer></manufacturer>";
				echo "</media>";
				
			}
			
			while($iList = mysql_fetch_object($getImages)){
				
				$id_image = $iList->id_image;
				$media_type = $iList->media_type;
				$tags = $iList->tags;
				$modality = $iList->modality;
				$organ = $iList->organ;
				$thumbnail = $iList->location_thumb;
				$mediaLocator = $iList->location_image;
				$lastname = $iList->lastname;
				$firstname = $iList->firstname;
				$upload_date = $iList->upload_date;
				$windowCenter = $iList->window_center;
				$windowWidth = $iList->window_width;
				$lat = $iList->laterality;
				$imageComment = $iList->image_comment;
				$contrast = $iList->contrast;
				$mrAquistitionType = $iList->mr_aquisitiontype;
				$sequenceName = $iList->sequence_name;
				$sliceThickness = $iList->slice_thickness;
				$kv = $iList->kv;
				$protocolName = $iList->protocol_name;
				$kernel = $iList->kernel;
				$mrCoil = $iList->mr_coil;
				$flipAngle = $iList->flip_angle;
				$patPos = $iList->pat_pos;
				$sens = $iList->sens;
				$man = $iList->manufacturer;
				$editor = $iList->upload_user;
				
				$date = getDisplayDate($upload_date);
				
				echo "<media>";
					echo "<mediaId>";
					echo $id_image;
					echo "</mediaId>";
					echo "<mediaType>";
					echo $media_type;
					echo "</mediaType>";
					echo "<tags>";
					echo $tags;
					echo "</tags>";
					echo "<modality>";
					echo $modality;
					echo "</modality>";
					echo "<organ>";
					echo $organ;
					echo "</organ>";
					echo "<thumbnail>";
					echo $thumbnail;
					echo "</thumbnail>";
					echo "<mediaLocator>";
					echo $mediaLocator;
					echo "</mediaLocator>";
					echo "<mediaEditor>";
					echo $firstname." ".$lastname;
					echo "</mediaEditor>";
					echo "<mediaEditorId>";
					echo $editor;
					echo "</mediaEditorId>";
					echo "<uploadDate>";
					echo $date;
					echo "</uploadDate>";
					echo "<windowCenter>";
					echo $windowCenter;
					echo "</windowCenter>";
					echo "<windowWidth>";
					echo $windowWidth;
					echo "</windowWidth>";
					echo "<laterality>";
					echo $lat;
					echo "</laterality>";
					echo "<imageComment>";
					echo $imageComment;
					echo "</imageComment>";
					echo "<contrast>";
					echo $contrast;
					echo "</contrast>";
					echo "<mrAquisitionType>";
					echo $mrAquistitionType;
					echo "</mrAquisitionType>";
					echo "<sequenceName>";
					echo $sequenceName;
					echo "</sequenceName>";
					echo "<sliceThickness>";
					echo $sliceThickness;
					echo "</sliceThickness>";
					echo "<kV>";
					echo $kv;
					echo "</kV>";
					echo "<protocolName>";
					echo $protocolName;
					echo "</protocolName>";
					echo "<kernel>";
					echo $kernel;
					echo "</kernel>";
					echo "<mrCoil>";
					echo $mrCoil;
					echo "</mrCoil>";
					echo "<flipAngle>";
					echo $flipAngle;
					echo "</flipAngle>";
					echo "<patPos>";
					echo $patPos;
					echo "</patPos>";
					echo "<sens>";
					echo $sens;
					echo "</sens>";
					echo "<manufacturer>";
					echo $man;
					echo "</manufacturer>";
					
				echo "</media>";
			}
	
	echo "</mediaList>";
	
} 
 
/*
 * GETMEDIABYEDITOR
 */
function getMediaByEditor($mediaEditor){
	
	require('../includes/gset.php');
	$sql_getMedia = "SELECT upload_user, id_media, tags, modality, organ, location_thumb, location_media, firstname, lastname, upload_date, media_type FROM media, staff WHERE media.upload_user = '$mediaEditor' AND (media.upload_user = staff.id_staff)";
	
	include ('../includes/database/connect.php');
	$getMedia = mysql_query($sql_getMedia);
	include ('../includes/database/closedb.php');
	
	// Writing XML Response Header
	header("Content-type: text/xml"); 
	echo "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>";
	echo "<mediaList>";
	
	while ($med = mysql_fetch_object($getMedia)){
		
		$idmedia = $med->id_media;
		$tags = $med->tags;
		$mod = $med->modality;
		$org = $med->organ;
		$thumb = $med->location_thumb;
		$media = $med->location_media;
		$firstname = $med->firstname;
		$lastname = $med->lastname;
		$type = $med->media_type;
		$lastmodified = $med->upload_date;
		$editor = $med->upload_user;
		
		$date = getDisplayDate($lastmodified);
		
		echo "<media>";
			echo "<mediaId>";
			echo $idmedia;
			echo "</mediaId>";
			echo "<mediaType>";
			echo $type;
			echo "</mediaType>";
			echo "<tags>";
			echo $tags;
			echo "</tags>";
			echo "<modality>";
			echo $mod;
			echo "</modality>";
			echo "<organ>";
			echo $org;
			echo "</organ>";
			echo "<thumbnail>";
			echo $thumb;
			echo "</thumbnail>";
			echo "<mediaLocator>";
			echo $media;
			echo "</mediaLocator>";
			echo "<mediaEditor>";
			echo $firstname." ".$lastname;
			echo "</mediaEditor>";
			echo "<mediaEditor>";
			echo $editor;
			echo "</mediaEditor>";
			echo "<uploadDate>";
			echo $date;
			echo "</uploadDate>";
		echo "</media>";
	}
	echo "</mediaList>";	
		
} 
 
 
 
/*
 * FUNCTION GETDISPLAYDATE requires the blogdate integer and transforms the integer into a nls specific text.
 */
function getDisplayDate($blogdate) {
	
	require('../includes/gset.php');
	
	// Defining response language
	$session_language = $_SESSION['lang'];
	if ($session_language == "") {
	
		// Assuming Controller has not been triggered by a PHP Session
		if ($lang == 1)	{
			require ('../includes/language/german.php');	
		} elseif($lang == 2){
			require ('../includes/language/english.php');
		} elseif($lang == 3){
			require ('../includes/language/french.php');
		}
			
	}
	
	$aktuelle_zeit = time();
	$lessoneminute = $aktuelle_zeit - 60;
	$lessonehour = $aktuelle_zeit - 3600;
	$lessoneday = $aktuelle_zeit - 86400;
	$yesterday = $aktuelle_zeit - 172800;
	$week = $aktuelle_zeit - 604800;
	$twoweeks = $aktuelle_zeit - 1209600;
	$month = $aktuelle_zeit - 2419200;
	$twomonths = $aktuelle_zeit - 4838400;
	$halfyear = $aktuelle_zeit - 14515200;
	$year = $aktuelle_zeit - 29030400;	
					
	if ($blogdate > $lessoneminute){
	$display_blogdate = $nls_lessoneminute;
	} elseif ($blogdate > $lessonehour){
	$display_blogdate = $nls_lessonehour;
	} elseif ($blogdate > $lessoneday){
	$display_blogdate = $nls_lessoneday;
	} elseif ($blogdate > $yesterday) {
	$display_blogdate = $nls_yesterday;
	} elseif ($blogdate > $week){
	$display_blogdate = $nls_week;
	} elseif ($blogdate > $twoweeks){
	$display_blogdate = $nls_twoweeks;
	} elseif ($blogdate > $month){
	$display_blogdate = $nls_month;
	} elseif ($blogdate > $twomonths){
	$display_blogdate = $nls_twomonths;
	} elseif ($blogdate > $halfyear){
	$display_blogdate = $nls_halfyear;
	} elseif ($blogdate > $year){
	$display_blogdate = $nls_year;
	} else {
	$display_blogdate = $nls_older;
	}

	return $display_blogdate;
}


?>